package com.ddpt.permission.dubbo.tokenVerify;

import com.lh.center.common.constant.RedisPrefix;
import com.lh.center.common.enums.MarketingApp;
import com.lh.center.permission.api.dubbo.TokenVerifyService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.data.redis.core.StringRedisTemplate;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@Slf4j
@DubboService(group = "tingtangUserLogin",interfaceName = "com.lh.center.permission.api.dubbo.TokenVerifyService")
public class TingtangUserTokenVerifyServiceImpl implements TokenVerifyService {

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public void refresh(String token) {
        stringRedisTemplate.expire(RedisPrefix.USER_TINGTANG_USER_TOKEN + token,1, TimeUnit.DAYS);
    }

    @Override
    public String getInfo(String token) {
        log.info("即将获取用户token ======");
        refresh(token);
        return stringRedisTemplate.opsForValue().get(wholeToken(MarketingApp.tingtang,token));
    }
}
